package org.zhouhe.web.tag.function;

public class BtnEditFunction {
	private String funName;
	private String dataGridId;
	private String winId;
	private String title;
	private String url;
	
	public BtnEditFunction(String funName, String winId, String dataGridId, String title, String url){
		this.funName = funName;
		this.dataGridId = dataGridId;
		this.winId = winId;
		this.title = title;
		this.url = url;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("\r\n  function "+ funName +"(){");
		sb.append("\r\n    var row = $('#"+ dataGridId +"').datagrid('getSelected');");
		sb.append("\r\n    if (row){ ");
		sb.append("\r\n      $('#"+ winId +"').dialog('open').dialog('setTitle','"+ title +"');");
		sb.append("\r\n		 $('#"+ winId +"').dialog('resize',{});");
		sb.append("\r\n      $('#"+ winId +"').find('form').form('load',row);");
		sb.append("\r\n      $('#"+ winId +"').data('url', '"+ url +"');");
		sb.append("\r\n    } else {");
		sb.append("\r\n      alert('请选择要修改的记录。')");
		sb.append("\r\n    }");
		sb.append("\r\n  }");
		return sb.toString();
	}
}
